/*
 * Alberto De Pena
 * Applied Algorithms
 * espanol.cpp
 *
 */
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;


void main()
{
    ifstream fin( "espanol.in" );
    ofstream fout( "espanol.out" );

    string Word;
    vector<string> Dictionary;

    int words = 0;
    fin >> words;

    fin.get();
    for( int i = 0; i < words; i++ )
    {
        getline( fin, Word );
        Dictionary.push_back( Word );
    }

    for( size_t i = 0; i < Dictionary.size(); i++ )
    {
        for( size_t n = 0; n < Dictionary.at(i).size(); n++ )
        {
            if( Dictionary.at(i).find( "~n" ) <= Dictionary.at(i).size() )
                 Dictionary.at(i).replace(  Dictionary.at(i).find( "~n" ), 2, "nzz" );
            else if ( Dictionary.at(i).find( "ch" ) <= Dictionary.at(i).size() )
                 Dictionary.at(i).replace(  Dictionary.at(i).find( "ch" ), 2, "czz" );
            else if ( Dictionary.at(i).find( "ll" ) <= Dictionary.at(i).size() )
                 Dictionary.at(i).replace(  Dictionary.at(i).find( "ll" ), 2, "lzz" );
            else if ( Dictionary.at(i).find( "rr" ) <= Dictionary.at(i).size() )
                 Dictionary.at(i).replace(  Dictionary.at(i).find( "rr" ), 2, "rzz" );
        }
    }

    sort( Dictionary.begin(), Dictionary.end() );

    for( size_t i = 0; i < Dictionary.size(); i++ )
    {
        for( size_t n = 0; n < Dictionary.at(i).size(); n++ )
        {
            if( Dictionary.at(i).find( "nzz" ) <= Dictionary.at(i).size() )
                 Dictionary.at(i).replace(  Dictionary.at(i).find( "nzz" ), 3, "~n" );
            else if ( Dictionary.at(i).find( "czz" ) <= Dictionary.at(i).size() )
                 Dictionary.at(i).replace(  Dictionary.at(i).find( "czz" ), 3, "ch" );
            else if ( Dictionary.at(i).find( "lzz" ) <= Dictionary.at(i).size() )
                 Dictionary.at(i).replace(  Dictionary.at(i).find( "lzz" ), 3, "ll" );
            else if ( Dictionary.at(i).find( "rzz" ) <= Dictionary.at(i).size() )
                 Dictionary.at(i).replace(  Dictionary.at(i).find( "rzz" ), 3, "rr" );
        }
    }

    for( size_t i = 0; i < Dictionary.size(); i++ )
    {
        fout << Dictionary.at(i) << endl;
    }

    fin.close();
    fout.close();
}


